<?php
namespace app\admin\controller;

class AjaxUploads extends \think\Controller
{
	public function uploads($exts=['mp4','gif','png','jpeg','zip','rar','doc','docx','jpg'], $rule='time'){
		 if (empty($_FILES)){
                        return; 
         }

         $upload = new \org\Upload();
         $upload->maxSize  = 9993145728 ;
         $upload->saveRule = $rule;
         $upload->allowExts  = $exts;
         $upload->savePath = "public/uploads/";
         if(false == $info = $upload->uploadOne($_FILES['file']))
             return;
         return json_encode($info[0]);
    } 

	public function img(){
        return $this->uploads(['jpg', 'gif', 'png', 'jpeg','mp4']);
    } 

	public function file(){
        return $this->uploads(['zip','rar','doc','docx','pdf','mp4'],$rule='');
    } 

   //修改一下，用于上传前台的文件
    public function ex_uploads($exts=['mp4','gif','png','jpeg','zip','rar','doc','docx','jpg'], $rule='time'){
         if (empty($_FILES)){
                        return; 
         }

         $upload = new \org\Upload();
         $upload->maxSize  = 93145728 ;
         $upload->saveRule = $rule;
         $upload->allowExts  = $exts;
         $upload->savePath = "public/uploads/member/";
         if(false == $info = $upload->uploadOne($_FILES['file'])){
            return; 
         } 
            
         return json_encode($info[0]);
    } 




    public function ex_img(){
        return $this->ex_uploads(['jpg', 'gif', 'png', 'jpeg']);
    } 





} 
